package com.example.ssm.controller;

import com.example.ssm.entity.UserInfo;
import com.example.ssm.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/userinfo")
public class UserInfoController {
    
    @Autowired
    private UserInfoService userInfoService;
    
    @GetMapping("/list")
    public List<UserInfo> list() {
        return userInfoService.list();
    }
    
    @GetMapping("/{username}")
    public UserInfo getByUsername(@PathVariable String username) {
        return userInfoService.getByUsername(username);
    }
    
    @PostMapping("/save")
    public boolean save(@RequestBody UserInfo userInfo) {
        return userInfoService.save(userInfo);
    }
    
    @PutMapping("/update")
    public boolean update(@RequestBody UserInfo userInfo) {
        return userInfoService.updateById(userInfo);
    }
    
    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Long id) {
        return userInfoService.removeById(id);
    }
} 